<!--
 * @Author: your name
 * @Date: 2021-09-07 10:14:25
 * @LastEditTime: 2021-09-07 10:59:40
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \briup\5-javascript\day12\7-事件捕获.html
-->
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .outer {
            border: 1px solid royalblue;
            width: 300px;
            height: 300px;
        }
        
        .center {
            border: 1px solid royalblue;
            width: 200px;
            height: 200px;
        }
        
        .inner {
            border: 1px solid royalblue;
            width: 100px;
            height: 100px;
        }
    </style>
</head>

<body>
    <div class=outer>
        <div class="center">
            <div class="inner">
                hello
            </div>
        </div>
    </div>
</body>
<script>
    var inner = document.getElementsByClassName("inner")[0];
    var center = document.getElementsByClassName("center")[0];
    var outer = document.getElementsByClassName("outer")[0];
    //事件监听  addEventListener()
    outer.addEventListener('click', function() {
        console.log("outer")
    }, true);
    center.addEventListener('click', function() {
        console.log("center")
    }, true);
    inner.addEventListener('click', function() {
        console.log("inner")
    }, true);
</script>

</html>